package com.muyu.danmo.service.impl;

import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.danmo.domain.DanmoUaweFollow;
import com.muyu.danmo.mapper.DanmoUaweFollowMapper;
import com.muyu.danmo.req.DanmoFollowUserListReq;
import com.muyu.danmo.req.DanmoUaweFollowReq;
import com.muyu.danmo.service.IDanmoUaweFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户关注Service业务层处理
 *
 * @author yangle
 * @date 2024-09-28
 */
@Service
public class DanmoUaweFollowServiceImpl implements IDanmoUaweFollowService
{
    @Autowired
    private DanmoUaweFollowMapper danmoUaweFollowMapper;

    /**
     * 查询用户关注
     *
     * @param id 用户关注主键
     * @return 用户关注
     */
    @Override
    public DanmoUaweFollow selectDanmoUaweFollowById(Long id)
    {
        return danmoUaweFollowMapper.selectDanmoUaweFollowById(id);
    }

    /**
     * 查询用户关注列表
     *
     * @param danmoUaweFollow 用户关注
     * @return 用户关注
     */
    @Override
    public List<DanmoUaweFollow> selectDanmoUaweFollowList(DanmoUaweFollow danmoUaweFollow)
    {
        return danmoUaweFollowMapper.selectDanmoUaweFollowList(danmoUaweFollow);
    }

    /**
     * 新增用户关注
     *
     * @param danmoUaweFollow 用户关注
     * @return 结果
     */
    @Override
    public int insertDanmoUaweFollow(DanmoUaweFollow danmoUaweFollow)
    {
        danmoUaweFollow.setCreateTime(DateUtils.getNowDate());
        return danmoUaweFollowMapper.insertDanmoUaweFollow(danmoUaweFollow);
    }

    /**
     * 修改用户关注
     *
     * @param danmoUaweFollow 用户关注
     * @return 结果
     */
    @Override
    public int updateDanmoUaweFollow(DanmoUaweFollow danmoUaweFollow)
    {
        danmoUaweFollow.setUpdateTime(DateUtils.getNowDate());
        return danmoUaweFollowMapper.updateDanmoUaweFollow(danmoUaweFollow);
    }

    /**
     * 批量删除用户关注
     *
     * @param ids 需要删除的用户关注主键
     * @return 结果
     */
    @Override
    public int deleteDanmoUaweFollowByIds(Long[] ids)
    {
        return danmoUaweFollowMapper.deleteDanmoUaweFollowByIds(ids);
    }

    /**
     * 删除用户关注信息
     *
     * @param id 用户关注主键
     * @return 结果
     */
    @Override
    public int deleteDanmoUaweFollowById(Long id)
    {
        return danmoUaweFollowMapper.deleteDanmoUaweFollowById(id);
    }

    @Override
    public List<DanmoUaweFollow> followUserList(DanmoFollowUserListReq danmoUaweFollowReq) {

       return danmoUaweFollowMapper.followUserList(danmoUaweFollowReq);
    }

    @Override
    public List<DanmoUaweFollow> concernUserList(DanmoUaweFollowReq danmoUaweFollowReq) {
        return danmoUaweFollowMapper.concernUserList(danmoUaweFollowReq);
    }

    /**
     * 关注用户
     * @param danmoUaweFollow
     * @return
     */
    @Override
    public Result addFollow(DanmoUaweFollow danmoUaweFollow) {
        danmoUaweFollowMapper.addFollow(danmoUaweFollow);
        return Result.success("关注成功");
    }

    /**
     * 取消关注
     * @param danmoUaweFollow
     * @return
     */
    @Override
    public Result delFollow(DanmoUaweFollow danmoUaweFollow) {
        danmoUaweFollowMapper.delFollow(danmoUaweFollow);
        return Result.error("取消关注");
    }
}
